home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg3.cab / table2.xsl < prev    next >
Extensible Markup Language  |  2005-09-10  |  9KB  |  218 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.     OpenOffice.org - a multi-platform office productivity suite
  5.  
  6.     $RCSfile: table.xsl,v $
  7.  
  8.     $Revision: 1.5 $
  9.  
  10.     last change: $Author: rt $ $Date: 2005/09/08 22:10:09 $
  11.  
  12.     The Contents of this file are made available subject to
  13.     the terms of GNU Lesser General Public License Version 2.1.
  14.  
  15.  
  16.       GNU Lesser General Public License Version 2.1
  17.       =============================================
  18.       Copyright 2005 by Sun Microsystems, Inc.
  19.       901 San Antonio Road, Palo Alto, CA 94303, USA
  20.  
  21.       This library is free software; you can redistribute it and/or
  22.       modify it under the terms of the GNU Lesser General Public
  23.       License version 2.1, as published by the Free Software Foundation.
  24.  
  25.       This library is distributed in the hope that it will be useful,
  26.       but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28.       Lesser General Public License for more details.
  29.  
  30.       You should have received a copy of the GNU Lesser General Public
  31.       License along with this library; if not, write to the Free Software
  32.       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33.       MA  02111-1307  USA
  34.  
  35. -->
  36. <!--
  37.     For further documentation and updates visit http://xml.openoffice.org/sx2ml
  38. -->
  39. <xsl:stylesheet version="1.0"
  40.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  41.                 xmlns:office="http://openoffice.org/2000/office"
  42.                 xmlns:style="http://openoffice.org/2000/style"
  43.                 xmlns:text="http://openoffice.org/2000/text"
  44.                 xmlns:table="http://openoffice.org/2000/table"
  45.                 xmlns:draw="http://openoffice.org/2000/drawing"
  46.                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
  47.                 xmlns:xlink="http://www.w3.org/1999/xlink"
  48.                 xmlns:number="http://openoffice.org/2000/datastyle"
  49.                 xmlns:svg="http://www.w3.org/2000/svg"
  50.                 xmlns:chart="http://openoffice.org/2000/chart"
  51.                 xmlns:dr3d="http://openoffice.org/2000/dr3d"
  52.                 xmlns:math="http://www.w3.org/1998/Math/MathML"
  53.                 xmlns:form="http://openoffice.org/2000/form"
  54.                 xmlns:script="http://openoffice.org/2000/script"
  55.                 xmlns:dc="http://purl.org/dc/elements/1.1/"
  56.                 xmlns:meta="http://openoffice.org/2000/meta"
  57.                 xmlns:config="http://openoffice.org/2001/config"
  58.                 xmlns:help="http://openoffice.org/2000/help"
  59.                 exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script dc meta config help"
  60.                 xmlns="http://www.w3.org/1999/xhtml">
  61.  
  62.  
  63.  
  64.     <!-- current node is a table:table or table:sub-table -->
  65.     <xsl:template name="create-table-children">
  66.         <xsl:param name="globalData" />
  67.         <xsl:param name="allVisibleTableRows" />
  68.         <xsl:param name="allTableColumns" />
  69.  
  70.         <xsl:element name="colgroup">
  71.             <xsl:for-each select="$allTableColumns/table:table-column">
  72.                 <xsl:if test="not(@table:visibility = 'collapse' or @table:visibility = 'filter')">
  73.                     <xsl:element name="col">
  74.                         <xsl:variable name="value" select="$globalData/all-ooo-styles/style[@style:name = current()/@table:style-name]/style:properties/@style:column-width" />
  75.                         <xsl:if test="$value">
  76.                             <xsl:attribute name="width">
  77.                                 <!-- using the absolute width, problems with the relative in browser (in OOo style:rel-column-width) -->
  78.                                 <xsl:call-template name="convert2px">
  79.                                     <xsl:with-param name="value" select="$globalData/all-ooo-styles/style[@style:name = current()/@table:style-name]/style:properties/@style:column-width" />
  80.                                 </xsl:call-template>
  81.                             </xsl:attribute>
  82.                         </xsl:if>
  83.                     </xsl:element>
  84.                     <!-- *** the column-style ***
  85.                     <xsl:attribute name="width">
  86.                         <xsl:variable name="currentColumnStyleName" select="$allTableColumns/table:table-column[position() = $columnPosition]/@table:style-name" />
  87.                         <xsl:value-of select="$globalData/all-ooo-styles/style[@style:name = $currentColumnStyleName]/style:properties/@style:column-width" />
  88.                     </xsl:attribute>-->
  89.                 </xsl:if>
  90.             </xsl:for-each>
  91.         </xsl:element>
  92.  
  93.         <xsl:call-template name="create-table-rows">
  94.             <xsl:with-param name="globalData"           select="$globalData" />
  95.             <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  96.             <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  97.         </xsl:call-template>
  98.     </xsl:template>
  99.  
  100.  
  101.  
  102.     <!-- Creating the content of a table content using CSS styles -->
  103.     <xsl:template name="create-table-cell-content">
  104.         <xsl:param name="tableDataType" />
  105.         <xsl:param name="globalData" />
  106.         <xsl:param name="allTableColumns" />
  107.         <xsl:param name="columnPosition" />
  108.         <xsl:param name="currentTableColumn" />
  109.  
  110.         <xsl:element name="{$tableDataType}">
  111.             <xsl:if test="$debugEnabled">
  112.                 <xsl:message>A table cell '<xsl:value-of select="$tableDataType" />' element has been added!</xsl:message>
  113.             </xsl:if>
  114.  
  115.             <!-- if parser reads DTD the default is set to '1' -->
  116.             <xsl:if test="@table:number-columns-spanned and @table:number-columns-spanned > 1">
  117.                 <xsl:attribute name="colspan">
  118.                     <xsl:value-of select="@table:number-columns-spanned" />
  119.                 </xsl:attribute>
  120.             </xsl:if>
  121.             <!-- if parser reads DTD the default is set to '1' -->
  122.             <xsl:if test="@table:number-rows-spanned and @table:number-rows-spanned > 1">
  123.                 <xsl:attribute name="rowspan">
  124.                     <xsl:value-of select="@table:number-rows-spanned" />
  125.                 </xsl:attribute>
  126.             </xsl:if>
  127.  
  128.  
  129.             <!-- *** the cell-style *** -->
  130.             <!-- The cell style has no conclusion with the column style, so we switch the order/priorities due to browser issues
  131.  
  132.                 The cell-style depends on two attributes:
  133.  
  134.                 1) table:style-name - the style properties of cell. When they exist, a default alignement (cp. below) will be added for the
  135.                                       case of no alignment in the style exist.
  136.  
  137.                 2) table:value-type - the value type of the table-cell giving the default alignments.
  138.                                       By default a string value is left aligned, all other are aligned:right.
  139.             -->
  140.             <xsl:choose>
  141.                 <xsl:when test="@table:style-name">
  142.                     <xsl:call-template name="set-styles">
  143.                         <xsl:with-param name="globalData" select="$globalData" />
  144.                         <xsl:with-param name="styleName" select="@table:style-name" />
  145.                         <xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
  146.                     </xsl:call-template>
  147.                 </xsl:when>
  148.                 <xsl:otherwise>
  149.                     <!-- Cells without a style use the 'table:default-cell-style-name'
  150.                          when there is no default cell style specified for the current column. -->
  151.                     <xsl:variable name="defaultCellStyleName" select="$currentTableColumn/@table:default-cell-style-name" />
  152.                     <xsl:choose>
  153.                         <xsl:when test="$defaultCellStyleName">
  154.                             <xsl:call-template name="set-styles">
  155.                                 <xsl:with-param name="globalData" select="$globalData" />
  156.                                 <xsl:with-param name="styleName" select="$defaultCellStyleName" />
  157.                                 <xsl:with-param name="currentTableColumn" select="$currentTableColumn" />
  158.                             </xsl:call-template>
  159.                         </xsl:when>
  160.                         <xsl:otherwise>
  161.                             <!-- No cell style exists, nor a default table cell style for the column -->
  162.                             <xsl:attribute name="style">
  163.                                 <!-- sets cell alignment dependent of cell value type -->
  164.                                 <xsl:call-template name="set-cell-alignment" />
  165.                             </xsl:attribute>
  166.                         </xsl:otherwise>
  167.                     </xsl:choose>
  168.                 </xsl:otherwise>
  169.             </xsl:choose>
  170.  
  171.             <xsl:apply-templates>
  172.                 <xsl:with-param name="globalData" select="$globalData" />
  173.             </xsl:apply-templates>
  174.  
  175.         </xsl:element>
  176.     </xsl:template>
  177.  
  178.  
  179.     <!-- Sets the cell alignment by the 'table:value-type' of the 'table:table-cell'.
  180.          Strings have a left alignment, other values right -->
  181.     <xsl:template name="set-cell-alignment">
  182.         <xsl:choose>
  183.             <xsl:when test="@table:value-type and not(@table:value-type = 'string')">text-align:right; </xsl:when>
  184.             <xsl:otherwise>text-align:left;</xsl:otherwise>
  185.         </xsl:choose>
  186.     </xsl:template>
  187.  
  188.  
  189.  
  190.     <!-- Sets styles of a cell -->
  191.     <xsl:template name="set-styles">
  192.         <xsl:param name="globalData" />
  193.         <xsl:param name="styleName" />
  194.         <xsl:param name="currentTableColumn" />
  195.  
  196.         <xsl:attribute name="style">
  197.             <!-- sets cell alignment dependent of cell value type -->
  198.             <xsl:call-template name="set-cell-alignment" />
  199.  
  200.             <!-- set column style (disjunct of cell style) -->
  201.             <xsl:value-of select="$globalData/all-styles/style[@style:name = $currentTableColumn/@table:style-name]/final-properties" />
  202.  
  203.            <xsl:if test="$outputType = 'CSS_INLINED'">
  204.                <!-- cell style inlined -->
  205.                <xsl:value-of select="$globalData/all-styles/style[@style:name = $styleName]/final-properties" />
  206.            </xsl:if>
  207.        </xsl:attribute>
  208.  
  209.        <xsl:if test="$outputType = 'CSS_HEADER'">
  210.            <!-- cell style header -->
  211.            <xsl:attribute name="class">
  212.                <xsl:value-of select="translate($styleName, '. %()/\+', '')" />
  213.            </xsl:attribute>
  214.        </xsl:if>
  215.     </xsl:template>
  216. </xsl:stylesheet>
  217.  
  218.